<template>
	<vk-data-drawer
		v-model="value.show"
		:title="page.title"
		:top="page.top"
		:width="page.width"
		:show-header="false"
	>
		<view v-if="value.item && value.show">
			<view style="display: flex;align-items: center;padding: 0 10px;">
				<view style="flex: 1;">
					<text>订单号：{{ value.item.order_no }}</text>
					<text style="margin-left: 20px;">付款金额：{{ vk.pubfn.priceFilter(value.item.amount_info.payment_amount) }}</text>
					<text style="margin-left: 20px;">退款金额：{{ vk.pubfn.priceFilter(value.item.amount_info.refund_amount) }}</text>
				</view>
				<view style="text-align: right;font-size: 25px;cursor: pointer;" @click="close">×</view>
			</view>

			<view style="padding: 15px;">
				<!-- 页面主体内容开始 -->
				<el-tabs v-model="pageName" type="card">
					<el-tab-pane :label="item.title" :name="item.name" v-for="(item, index) in tabs" :key="index"></el-tab-pane>
				</el-tabs>
				<keep-alive>
					<component :is="pageName" :orderInfo="value.item"></component>
				</keep-alive>
				<!-- 页面主体内容结束 -->
			</view>
		</view>
	</vk-data-drawer>
</template>

<script>
var that; // 当前页面对象
var vk = uni.vk; // vk实例

import userReward from "./records/user-reward"
import userPerformance from "./records/user-performance"

export default {
	components: {
		userReward,
		userPerformance
	},
	props: {
		value: {
			Type: Object,
			default: function() {
				return {
					show: false,
					mode: "",
					item: "",
					options: "",
					pageName:""
				};
			}
		}
	},
	data: function() {
		// 组件创建时,进行数据初始化
		return {
			pageName: "user-reward",
			tabs: [
				{ title: "奖励明细", name: "user-reward" },
				{ title: "业绩明细", name: "user-performance" },
			],
			page: {
				title: "标题",
				top: "7vh",
				width: "1300px",
				loading: false
			}
		};
	},
	mounted() {
		that = this;
		that.init();
	},
	methods: {
		// 初始化
		init() {
			let { value } = that;
			that._input(value);
		},
		_input(value) {
			that.$emit("input", value);
		},
		// 监听 - 页面打开
		onOpen() {
			that = this;
			let { value = {} } = that;
			let { item } = value;
			that.pageName = that.value.pageName || "user-reward";
			//that.form1 = vk.pubfn.copyObject(item);
		},
		// 监听 - 页面关闭
		onClose() {},
		// 打开页面
		open() {
			let { value } = that;
			value.show = true;
			that._input(value);
		},
		// 关闭页面
		close() {
			let { value } = that;
			value.show = false;
			that._input(value);
		}
	},
	watch: {
		"value.show": {
			handler(newValue, oldValue) {
				let that = this;
				if (newValue) {
					that.onOpen();
				} else {
					that.onClose();
				}
			}
		}
	},
	// 计算属性
	computed: {

	}
};
</script>

<style lang="scss" scoped>

</style>
